package com.yang.doctorrecruitment.dao;

import com.yang.doctorrecruitment.dto.BaseInfomation;
import com.yang.doctorrecruitment.dto.UserResume;
import com.yang.doctorrecruitment.utils.DBManager;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class GetUserResumeDAO {
    private static Connection conn;
    public static UserResume getUserResume(String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" select * from userresume where UserID=?";
        UserResume userResume=new UserResume();
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,UserID);
            res=statement.executeQuery();
            while(res.next()){
                userResume.setBaseInfomation(res.getString("BaseInfomation"));
                //这里有可能是空的
                userResume.setJobIntension(res.getString("JobIntension"));
                userResume.setWorkExperience(res.getString("WorkExperience"));
                userResume.setProjectExperience(res.getString("ProjectExperience"));
                userResume.setEducationExperience(res.getString("EducationExperience"));
                userResume.setSchoolSituation(res.getString("SchoolSituation"));
                userResume.setSkills(res.getString("Skills"));
                userResume.setAppendInformation(res.getString("AppendInformation"));
                userResume.setUserID(UserID);
                userResume.setExtraResume(res.getString("ExtraResume"));
                return userResume;

            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return null;
    }
}
